package com.leo.foodmaster.ureport2.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.bstek.ureport.Utils;
import com.bstek.ureport.export.ExportManager;
import com.bstek.ureport.export.html.HtmlReport;
import com.leo.foodmaster.ureport2.service.IPurchaseBillReportService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author ：Leo
 * @since ：2021/10/16 17:34
 */
@Service
public class PurchaseBillReportServiceImpl implements IPurchaseBillReportService {

    /**
     * 获取HtmlReporter
     * @param purchaseBillId 采购单Id
     * @return HtmlReport
     */
    @Override
    public HtmlReport getPurchaseBillHtml(Long purchaseBillId) {
        Map<String, Object> map = new HashMap<>(1);
        //设置查询参数
        if (BeanUtil.isNotEmpty(purchaseBillId)) {
            map.put("purchaseBillId", purchaseBillId);
        }
        //获取bean
        ExportManager exportManager=(ExportManager) Utils.getApplicationContext().getBean(ExportManager.BEAN_ID);
        return exportManager.exportHtml("customFile:purchaseBillReport.ureport.xml",
                System.getProperty("user.dir"), map,1);
    }
}
